//
//  WBStatusCell.swift
//  WeiboSwift
//
//  Created by hfwd on 2017/6/5.
//  Copyright © 2017年 hfwd. All rights reserved.
//

import UIKit

class WBStatusCell: UITableViewCell {
    
    var viewModel: WBStatusViewModel? {
        
        didSet {
            
            //微博正文
            statusLabel.text = viewModel?.status.text
            
            //姓名
            nameLabel.text = viewModel?.status.user?.screen_name
            
            //会员图标
            memberIcon.image = viewModel?.memberIcon
            
            //vip认证图标
            vipIcon.image = viewModel?.vipIcon
            
            // 用户头像
            iconView.sc_setImage(urlString: viewModel?.status.user?.profile_image_url, placeHolderImage: UIImage(named:"welcom_avatar"), isAvatar: true)
            
            //底部工具栏
            statusToolBar.viewModel = viewModel!
            
            statusPictureView.viewModel = viewModel
            
            retweetedTextLabel?.text = viewModel?.retweetedText
            
        }
    }

    /// 头像
    @IBOutlet weak var iconView: UIImageView!
    
    /// 姓名
    @IBOutlet weak var nameLabel: UILabel!
    
    /// vip认证图标
    @IBOutlet weak var vipIcon: UIImageView!
    
    /// 会员图标
    @IBOutlet weak var memberIcon: UIImageView!

    /// 时间
    @IBOutlet weak var timeLabel: UILabel!
    
    /// 来源
    @IBOutlet weak var sourceLabel: UILabel!
    
    /// 微博正文
    @IBOutlet weak var statusLabel: UILabel!

    /// 底部工具栏
    @IBOutlet weak var statusToolBar: WBStatusToolBar!
    
    /// 配图视图
    @IBOutlet weak var statusPictureView: WBStatusPictureView!
    
    /// 转发微博正文
    @IBOutlet weak var retweetedTextLabel: UILabel?
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        // 离屏渲染
        self.layer.drawsAsynchronously = true
        
        // 栅格化
        self.layer.shouldRasterize = true
        
        self.layer.rasterizationScale = UIScreen.main.scale
    }
}
